import { inject, computed, Ref } from "vue"

export default (props: { golbal: any }, data: any) => {
    const visibleComponent = inject<Ref<boolean>>("visibleComponent");

    const current = inject<any>("current");
    const hoverActive = inject<any>("hoverActive");
    const clickItem = (tree: any) => {
        visibleComponent && (visibleComponent.value = false);
        current.value = tree;
    };

    const classList = computed(() => {
        return [
            "ml-render-item",
            hoverActive.value === data.value && "ml-hover-active",
            current.value === data.value && "ml-active",
        ];
    });

    return {
        current,
        hoverActive,
        clickItem,
        classList,
    }
}